CaseFrontSheetDao.java 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. package thyyxxk.webserver.dao.his.casefrontsheet;
  2. import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  3. import org.apache.ibatis.annotations.*;
  4. import thyyxxk.webserver.entity.casefrontsheet.*;
  5. import thyyxxk.webserver.entity.covid.Region;
  6. import thyyxxk.webserver.entity.dictionary.CodeName;
  7. import thyyxxk.webserver.entity.dictionary.HisWjwMatchEntity;
  8. import java.util.Date;
  9. import java.util.List;
  10. import java.util.Map;
  11. /**
  12. * @author dj
  13. */
  14. @Mapper
  15. public interface CaseFrontSheetDao extends BaseMapper<CaseFrontsheetMain> {
  16. @Select("select count(1) from zy_actpatient where inpatient_no=#{bah} and admiss_times=#{times}")
  17. int selectActCount(@Param("bah") String bah, @Param("times") int times);
  18. @Select("select " +
  19. "bedNo=rtrim(bed_no)," +
  20. "bah=rtrim(inpatient_no)," +
  21. "times=rtrim(admiss_times)," +
  22. "name=rtrim(name)," +
  23. "sex,file_status," +
  24. "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=refer_physician), " +
  25. "admiss_date " +
  26. "from zy_actpatient with(nolock) where (small_dept=#{ward} or ward=#{ward}) and " +
  27. "charindex('$',inpatient_no)=0 " +
  28. "ORDER BY cast(bed_no AS int)")
  29. List<SheetOverview> getPatientOverview(@Param("ward") String ward);
  30. @Select("select " +
  31. "bedNo=rtrim(bed_no)," +
  32. "bah=rtrim(inpatient_no)," +
  33. "times=rtrim(admiss_times)," +
  34. "name=rtrim(name)," +
  35. "sex,file_status," +
  36. "doctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=refer_physician) " +
  37. "from zy_inactpatient with(nolock) where " +
  38. "dis_date>=#{start} and dis_date<=#{end} and " +
  39. "(small_dept=#{ward} or ward=#{ward}) and " +
  40. "charindex('$',inpatient_no)=0 " +
  41. "ORDER BY cast(bed_no AS int)")
  42. List<SheetOverview> getOutPatients(GetOutSheet param);
  43. @Select("select " +
  44. "healthCardNo=rtrim(health_card_no), " +
  45. "bah=rtrim(inpatient_no), " +
  46. "name=rtrim(name), " +
  47. "sex=rtrim(sex), " +
  48. "birthDate=birth_date, " +
  49. "country=rtrim(country), " +
  50. "birthPlace=rtrim(birth_place)," +
  51. "birthPlaceName=(select rtrim(name) from zd_district_code with(nolock) where code=birth_place), " +
  52. "nation=rtrim(nation_code), " +
  53. "socialNo=rtrim(social_no), " +
  54. "occupation=rtrim(occupation_code), " +
  55. "marriage=rtrim(marry_code), " +
  56. "livePlace=rtrim(home_street), " +
  57. "phone=rtrim(home_tel), " +
  58. "addrZipCode=rtrim(home_zipcode), " +
  59. "hkZipCode=rtrim(account_zipcode), " +
  60. "unitName=rtrim(employer_name)," +
  61. "unitPlace=rtrim(employer_street)," +
  62. "unitPhone=rtrim(employer_tel), " +
  63. "unitZipCode=rtrim(employer_zipcode), " +
  64. "contactName=rtrim(relation_name), " +
  65. "contactRelation=rtrim(relation_code), " +
  66. "contactPhone=(rtrim(relation_tel)) " +
  67. "from a_patient_mi with(nolock) " +
  68. "where inpatient_no=#{bah}")
  69. CaseFrontsheetMain getAPatientMi(@Param("bah") String bah);
  70. @Select("select sum(charge12) surgeryFee,sum(charge1) westMedicineFee,sum(charge2) chineseHerbalMedicineFee, " +
  71. "sum(charge10) anesthetizeFee,sum(charge28) chinesePatentMedicineFee,sum(charge19) careFee, " +
  72. "sum(charge25) generalTreatmentOperatingFee, surgicalFee=(sum(charge10) + sum(charge12)) from " +
  73. "zy_ledger_file with(nolock) where inpatient_no=#{bah} and admiss_times=#{times}")
  74. CaseFrontsheetMain getZyLedgerFile(@Param("bah") String bah, @Param("times") int times);
  75. @Select("select top 1 serial_no from t_injury_si_pat_info with(nolock) where pat_no=#{patNo} and times=#{times} order by ledger_sn desc")
  76. String selectInjurySerialNo(@Param("patNo") String patNo,
  77. @Param("times") Integer times);
  78. @Select("select [dbo].[judge_infant](#{bah}, #{times})")
  79. int getInfant(@Param("bah") String bah, @Param("times") int times);
  80. @Select("select max(start_time) from ${table} with(nolock) where inpatient_no=#{bah} " +
  81. "and admiss_times=#{times} and status_flag > '1' and isnull (group_no,'00')='00' " +
  82. "and order_code in ('06025','06026','06027','06053','05973')")
  83. Date getDismissDateFromYzActOrder(@Param("table") String table, @Param("bah") String bah, @Param("times") int times);
  84. @Select("select " +
  85. "admissTimes=#{times}, " +
  86. "rtrim(zk_ward) as transDeptCode," +
  87. "transDept=(select rtrim(name) from zd_unit_code with(nolock) where code=zk_ward)," +
  88. "rtrim(zk_ward) as dismissDeptCode," +
  89. "dismissDept=(select rtrim(name) from zd_unit_code with(nolock) where code=isnull(zk_ward,small_dept))," +
  90. "dismissWardCode=ward,admiss_date, " +
  91. "dismissWard=(select rtrim(name) from zd_unit_code with(nolock) where code=ward)," +
  92. "medType=(select top 1 med_type from t_si_pat_info with(nolock) where pat_no=#{bah} and times=#{times} order by ledger_sn desc), " +
  93. "insutype=(select top 1 insutype from t_si_pat_info with(nolock) where pat_no=#{bah} and times=#{times} order by ledger_sn desc), " +
  94. "dismissDate=(select max(start_time) from ${yzTable} with(nolock) where inpatient_no=#{bah} " +
  95. "and admiss_times=#{times} and status_flag > '1' and isnull (group_no,'00')='00' " +
  96. "and order_code in ('06025','06026','06027','06053','05973')), " +
  97. "rtrim(small_dept) as admissDeptCode, " +
  98. "admissDept=(select rtrim(name) from zd_unit_code with(nolock) where code=small_dept), " +
  99. "rtrim(admiss_ward) as admissWardCode, " +
  100. "admissWard=(select rtrim(name) from zd_unit_code with(nolock) where code=admiss_ward), " +
  101. "clinicDiagStr=rtrim(clinic_diag_str), " +
  102. "clinicDiagCode=rtrim(clinic_diag), " +
  103. "totalCost=total_charge, " +
  104. "selfPay=(select sum(last_balance) from zy_ledger_file with(nolock) " +
  105. "where inpatient_no=#{bah} and admiss_times=#{times} and ledger_sn>0)," +
  106. "autopsy=rtrim(autopsy_mark)," +
  107. "hasSurgery=rtrim(operation)," +
  108. "diagConform1=rtrim(diagnose_conform1)," +
  109. "diagConform2=rtrim(diagnose_conform2)," +
  110. "diagConform3=rtrim(diagnose_conform3)," +
  111. "diagConform4=rtrim(diagnose_conform4)," +
  112. "diagConform5=rtrim(diagnose_conform5)," +
  113. "pathologicDiagStr=rtrim(pathology_diag_comment)," +
  114. "pathologicDiagCode=rtrim(pathology_diag)," +
  115. "lendFlag=isnull(lend_flag, 0), " +
  116. "fileStatus=isnull(file_status, 0) " +
  117. "from ${table} with(nolock) where inpatient_no=#{bah} and admiss_times=#{times}")
  118. CaseFrontsheetMain getZyActPatient(@Param("table") String table, @Param("yzTable") String yzTable,
  119. @Param("bah") String bah, @Param("times") int times);
  120. @Select("select " +
  121. "payMethod=rtrim(pay_method)," +
  122. "ageDays=rtrim(age_days)," +
  123. "newBornWeight=rtrim(new_born_weight)," +
  124. "newBornAdmissWeight=rtrim(new_born_admiss_weight)," +
  125. "zyAdmissWay=rtrim(rytj)," +
  126. "nativePlace=rtrim(jg)," +
  127. "nativePlaceName=(select rtrim(name) from zd_district_code with(nolock) where code=jg)," +
  128. "hkPlace=rtrim(hkdz)," +
  129. "hkPlaceName=rtrim(hkdz2)," +
  130. "contactAddr=rtrim(lxdz)," +
  131. "contactAddrName=rtrim(lxdz2)," +
  132. "hkZipCode=rtrim(hkyb) " +
  133. "from batj_ba1 with(nolock) where bah=#{bah} and zycs=#{times}")
  134. CaseFrontsheetMain getBatjBa1(@Param("bah") String bah, @Param("times") int times);
  135. @Select("select " +
  136. "blh=rtrim(a.blzd_qph)," +
  137. "allergy=rtrim(a.gm_flag)," +
  138. "allergicMedicine=rtrim(a.gmwy)," +
  139. "hbsAg=rtrim(a.hbsag)," +
  140. "hcvAb=rtrim(a.hcv_vb)," +
  141. "hivAb=rtrim(a.hiv_vb)," +
  142. "tpAb=rtrim(a.tp_ab)," +
  143. "bloodType=rtrim(a.xx)," +
  144. "rh=rtrim(a.xx_rh)," +
  145. "deptLeader=rtrim(isnull(kzr, b.dept_director))," +
  146. "deptLeaderName=(select rtrim(name) from a_employee_mi with(nolock) where code=(isnull(kzr, b.dept_director)))," +
  147. "leaderDoctor=rtrim(isnull(zrys, b.dept_director))," +
  148. "leaderDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=(isnull(zrys, b.dept_director)))," +
  149. "mainDoctor=rtrim(isnull(zzys, b.consult_physician))," +
  150. "mainDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=(isnull(zzys, b.consult_physician)))," +
  151. "admissDoctor=rtrim(isnull(zyys, b.refer_physician))," +
  152. "admissDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=isnull(zyys, b.refer_physician))," +
  153. "dutyNurse=rtrim(a.job_nurse)," +
  154. "dutyNurseName=(select rtrim(name) from a_employee_mi with(nolock) where code=a.job_nurse)," +
  155. "studyDoctor=rtrim(a.jxys)," +
  156. "studyDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=jxys)," +
  157. "internshipDoctor=rtrim(a.sxys)," +
  158. "internshipDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=sxys)," +
  159. "coder=rtrim(a.bmy)," +
  160. "coderName=(select rtrim(name) from a_employee_mi with(nolock) where code=bmy)," +
  161. "qualityControlLevel=rtrim(a.bazl)," +
  162. "qualityControlDoctor=rtrim(a.zkys)," +
  163. "qualityControlDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=zkys)," +
  164. "qualityControlNurse=rtrim(a.zkhs)," +
  165. "qualityControlNurseName=(select rtrim(name) from a_employee_mi with(nolock) where code=zkhs)," +
  166. "qualityControlDate=a.barq," +
  167. "zyDismissWay=rtrim(a.lyfs)," +
  168. "dismissDestination=rtrim(a.jsjg)," +
  169. "admissAgainInOneMonth=rtrim(a.zzy_flag)," +
  170. "admissAgainPurpose=rtrim(a.zzy_md)," +
  171. "comaDaysBeforeAdmiss=rtrim(a.ryq_hmsj_day)," +
  172. "comaHoursBeforeAdmiss=rtrim(a.ryq_hmsj_hour)," +
  173. "comaMinutesBeforeAdmiss=rtrim(a.ryq_hmsj_min)," +
  174. "comaDaysAfterAdmiss=rtrim(a.ryh_hmsj_day)," +
  175. "comaHoursAfterAdmiss=rtrim(a.ryh_hmsj_hour)," +
  176. "comaMinutesAfterAdmiss=rtrim(a.ryh_hmsj_min)," +
  177. "rescueTimes=rtrim(a.qjcs)," +
  178. "rescueSuccessTimes=rtrim(a.cgcs)," +
  179. "caseClassification=rtrim(a.blfx)," +
  180. "hasIcu=rtrim(a.zzjh)," +
  181. "icuDays=rtrim(a.zzjh_day)," +
  182. "icuHours=rtrim(a.zzjh_hour)," +
  183. "monopathyManagement=rtrim(a.dbz)," +
  184. "clinicalPathwayManagement=rtrim(a.lclj)," +
  185. "drgsManagement=rtrim(a.drgs)," +
  186. "useAntibiotic=rtrim(a.kss)," +
  187. "bacilliculture=rtrim(a.xjpy)," +
  188. "statutoryEpidemic=rtrim(a.fdcrb)," +
  189. "hurtReasonName=rtrim(a.hurt_reason_name)," +
  190. "hurtReasonCode=rtrim(a.hurt_reason_code)," +
  191. "tumorLevelT=rtrim(a.tumor_level_t)," +
  192. "tumorLevelN=rtrim(a.tumor_level_n)," +
  193. "tumorLevelM=rtrim(a.tumor_level_m)," +
  194. "xxeApgar=rtrim(a.apgar) " +
  195. "from batj_ba2 a with(nolock), zy_actpatient b with(nolock) where " +
  196. "b.inpatient_no=a.bah and " +
  197. "a.bah=#{bah} and a.zycs=#{times}")
  198. CaseFrontsheetMain getBatjBa2ForInPatient(@Param("bah") String bah, @Param("times") int times);
  199. @Select("select " +
  200. "lateFlag=(select late_flag from t_case_frontsheet_main t where t.bah=#{bah} and t.admiss_times=#{times}), " +
  201. "fileStatus=(select file_status from t_case_frontsheet_main t where t.bah=#{bah} and t.admiss_times=#{times}), " +
  202. "signDate=(select sign_date from t_case_frontsheet_main t where t.bah=#{bah} and t.admiss_times=#{times}), " +
  203. "blh=rtrim(a.blzd_qph)," +
  204. "allergy=rtrim(a.gm_flag)," +
  205. "allergicMedicine=rtrim(a.gmwy)," +
  206. "hbsAg=rtrim(a.hbsag)," +
  207. "hcvAb=rtrim(a.hcv_vb)," +
  208. "hivAb=rtrim(a.hiv_vb)," +
  209. "tpAb=rtrim(a.tp_ab)," +
  210. "bloodType=rtrim(a.xx)," +
  211. "rh=rtrim(a.xx_rh)," +
  212. "deptLeader=rtrim(isnull(kzr, b.dept_director))," +
  213. "deptLeaderName=(select rtrim(name) from a_employee_mi with(nolock) where code=(isnull(kzr, b.dept_director)))," +
  214. "leaderDoctor=rtrim(isnull(zrys, b.dept_director))," +
  215. "leaderDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=(isnull(zrys, b.dept_director)))," +
  216. "mainDoctor=rtrim(isnull(zzys, b.consult_physician))," +
  217. "mainDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=(isnull(zzys, b.consult_physician)))," +
  218. "admissDoctor=rtrim(isnull(zyys, b.refer_physician))," +
  219. "admissDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=isnull(zyys, b.refer_physician))," +
  220. "dutyNurse=rtrim(a.job_nurse)," +
  221. "dutyNurseName=(select rtrim(name) from a_employee_mi with(nolock) where code=a.job_nurse)," +
  222. "studyDoctor=rtrim(a.jxys)," +
  223. "studyDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=jxys)," +
  224. "internshipDoctor=rtrim(a.sxys)," +
  225. "internshipDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=sxys)," +
  226. "coder=rtrim(a.bmy)," +
  227. "coderName=(select rtrim(name) from a_employee_mi with(nolock) where code=bmy)," +
  228. "qualityControlLevel=rtrim(a.bazl)," +
  229. "qualityControlDoctor=rtrim(a.zkys)," +
  230. "qualityControlDoctorName=(select rtrim(name) from a_employee_mi with(nolock) where code=zkys)," +
  231. "qualityControlNurse=rtrim(a.zkhs)," +
  232. "qualityControlNurseName=(select rtrim(name) from a_employee_mi with(nolock) where code=zkhs)," +
  233. "qualityControlDate=a.barq," +
  234. "zyDismissWay=rtrim(a.lyfs)," +
  235. "dismissDestination=rtrim(a.jsjg)," +
  236. "admissAgainInOneMonth=rtrim(a.zzy_flag)," +
  237. "admissAgainPurpose=rtrim(a.zzy_md)," +
  238. "comaDaysBeforeAdmiss=rtrim(a.ryq_hmsj_day)," +
  239. "comaHoursBeforeAdmiss=rtrim(a.ryq_hmsj_hour)," +
  240. "comaMinutesBeforeAdmiss=rtrim(a.ryq_hmsj_min)," +
  241. "comaDaysAfterAdmiss=rtrim(a.ryh_hmsj_day)," +
  242. "comaHoursAfterAdmiss=rtrim(a.ryh_hmsj_hour)," +
  243. "comaMinutesAfterAdmiss=rtrim(a.ryh_hmsj_min)," +
  244. "rescueTimes=rtrim(a.qjcs)," +
  245. "rescueSuccessTimes=rtrim(a.cgcs)," +
  246. "caseClassification=rtrim(a.blfx)," +
  247. "hasIcu=rtrim(a.zzjh)," +
  248. "icuDays=rtrim(a.zzjh_day)," +
  249. "icuHours=rtrim(a.zzjh_hour)," +
  250. "monopathyManagement=rtrim(a.dbz)," +
  251. "clinicalPathwayManagement=rtrim(a.lclj)," +
  252. "drgsManagement=rtrim(a.drgs)," +
  253. "useAntibiotic=rtrim(a.kss)," +
  254. "bacilliculture=rtrim(a.xjpy)," +
  255. "statutoryEpidemic=rtrim(a.fdcrb)," +
  256. "hurtReasonName=rtrim(a.hurt_reason_name)," +
  257. "hurtReasonCode=rtrim(a.hurt_reason_code)," +
  258. "tumorLevelT=rtrim(a.tumor_level_t)," +
  259. "tumorLevelN=rtrim(a.tumor_level_n)," +
  260. "tumorLevelM=rtrim(a.tumor_level_m)," +
  261. "xxeApgar=rtrim(a.apgar) " +
  262. "from batj_ba2 a with(nolock), zy_inactpatient b with(nolock) where " +
  263. "b.inpatient_no=a.bah and b.admiss_times=a.zycs and " +
  264. "a.bah=#{bah} and a.zycs=#{times}")
  265. CaseFrontsheetMain getBatjBa2ForOutPatient(@Param("bah") String bah, @Param("times") int times);
  266. @Select("select no=rtrim(dis_diag_no), name=rtrim(dis_diag_comment), " +
  267. "code=rtrim(dis_diag), admissStatus=rtrim(admiss_status), " +
  268. "dismissStatus=rtrim(dis_diag_status) from ba_first_page1 with(nolock) " +
  269. "where inpatient_no=#{bah} and admiss_times=#{times}")
  270. List<CaseFrontsheetDisdiag> getDisdiags(@Param("bah") String bah, @Param("times") int times);
  271. @Select("select rtrim(code) as code,rtrim(name) as name from zd_icd_code_new where code=#{code}")
  272. CaseFrontsheetDisdiag selectDiagInfoByCode(@Param("code") String code);
  273. @Select("select no=rtrim(ssxh)," +
  274. "name=rtrim(ssmc)," +
  275. "date=ssrq, " +
  276. "op_end_date,anst_start_date,anst_end_date, " +
  277. "level=rtrim(ssjb)," +
  278. "code=rtrim(ssbm)," +
  279. "operator=rtrim(ssys)," +
  280. "operatorName=(select rtrim(name) from a_employee_mi with(nolock) where code=ssys)," +
  281. "assistantOne=rtrim(sszs1)," +
  282. "assistantOneName=(select rtrim(name) from a_employee_mi with(nolock) where code=sszs1)," +
  283. "assistantTwo=rtrim(sszs2)," +
  284. "assistantTwoName=(select rtrim(name) from a_employee_mi with(nolock) where code=sszs2)," +
  285. "cut=rtrim(qkjb), " +
  286. "heal=rtrim(yhqk), " +
  287. "anaesthesia=rtrim(mzff)," +
  288. "anaesthesiaor=rtrim(mzys)," +
  289. "anaesthesiaorName=(select rtrim(name) from a_employee_mi with(nolock) where code=mzys) " +
  290. "from batj_ba4 with(nolock) " +
  291. "where bah=#{bah} and zycs=#{times}")
  292. List<CaseFrontsheetSurgery> getSurgeries(@Param("bah") String bah, @Param("times") int times);
  293. @Select("select rtrim(code) as code,name from zd_icd9_cm3 where code=#{code}")
  294. CaseFrontsheetSurgery selectSurgeryByCode(@Param("code") String code);
  295. @Select("select (select count(1) from yz_act_order with(nolock) where order_code in ('06026','06053','06027') " +
  296. "and inpatient_no=#{bah} and admiss_times=#{times}) + " +
  297. "(select count(1) from yz_inact_order with(nolock) where order_code in ('06026','06053','06027') and " +
  298. "inpatient_no=#{bah} and admiss_times=#{times})")
  299. int getDismissOrder(@Param("bah") String bah, @Param("times") int times);
  300. @Select("select (select count(1) from yz_act_order with(nolock) where order_code='05973' and inpatient_no=#{bah} " +
  301. "and admiss_times=#{times}) + (select count(1) from yz_inact_order with(nolock) where order_code='05973' " +
  302. "and inpatient_no=#{bah} and admiss_times=#{times})")
  303. int getDeathOrder(@Param("bah") String bah, @Param("times") int times);
  304. @Update("update a_patient_mi set name=#{name}, " +
  305. "sex=#{sex}, " +
  306. "health_card_no=#{healthCardNo}," +
  307. "birth_date=#{birthDate}, " +
  308. "country=#{country}, " +
  309. "birth_place=#{birthPlace}, " +
  310. "nation_code=#{nation}, " +
  311. "social_no=#{socialNo}, " +
  312. "occupation_code=#{occupation}, " +
  313. "marry_code=#{marriage}, " +
  314. "home_street=#{livePlace}, " + // max 32 char
  315. "home_tel=#{phone}, " +
  316. "home_zipcode=#{addrZipCode}, " +
  317. "account_street=#{hkPlaceName}, " + // max 20 char
  318. "account_zipcode=#{hkZipCode}, " +
  319. "employer_name=#{unitName}, " +
  320. "employer_street=#{unitPlace}, " + // max 32 char
  321. "employer_tel=#{unitPhone}, " +
  322. "employer_zipcode=#{unitZipCode}, " +
  323. "relation_name=#{contactName}, " +
  324. "relation_code=#{contactRelation}, " +
  325. "relation_street=#{contactAddrName}, " + // max 32 char
  326. "relation_tel=#{contactPhone} " +
  327. "where inpatient_no=#{bah}")
  328. void updateAPatientMi(CaseFrontsheetMain sheet);
  329. @Update("update a_patient_mi set province_code=#{province},city_code=#{city},district_code=#{district} " +
  330. "where inpatient_no=#{bah}")
  331. void updateAddressCascader(@Param("bah") String bah,
  332. @Param("province") Integer province,
  333. @Param("city") Integer city,
  334. @Param("district") Integer district);
  335. @Update("update zy_actpatient set autopsy_mark=#{autopsy},clinic_diag_str=#{clinicDiagStr}, " +
  336. "diagnose_conform1=#{dc1},diagnose_conform2=#{dc2},diagnose_conform3=#{dc3}," +
  337. "diagnose_conform4=#{dc4}, diagnose_conform5=#{dc5}, operation=#{hasSurgery}," +
  338. "pathology_diag_comment=#{pathologicDiagStr},pathology_diag=#{pathologicDiagCode}, " +
  339. "clinic_diag=#{clinicDiagCode} where inpatient_no=#{bah} and admiss_times=#{times}")
  340. void updateZyActPatient(@Param("bah") String bah, @Param("times") int times,
  341. @Param("autopsy") String autopsy,
  342. @Param("dc1") String dc1, @Param("dc2") String dc2,
  343. @Param("dc3") String dc3, @Param("dc4") String dc4,
  344. @Param("dc5") String dc5, @Param("hasSurgery") String hasSurgery,
  345. @Param("pathologicDiagStr") String pathologicDiagStr,
  346. @Param("pathologicDiagCode") String pathologicDiagCode,
  347. @Param("clinicDiagCode") String clinicDiagCode,
  348. @Param("clinicDiagStr") String clinicDiagStr);
  349. @Update("update zy_inactpatient set autopsy_mark=#{autopsy},clinic_diag_str=#{clinicDiagStr}, " +
  350. "diagnose_conform1=#{dc1},diagnose_conform2=#{dc2},diagnose_conform3=#{dc3}," +
  351. "diagnose_conform4=#{dc4}, diagnose_conform5=#{dc5}, operation=#{hasSurgery}," +
  352. "pathology_diag_comment=#{pathologicDiagStr},pathology_diag=#{pathologicDiagCode}, " +
  353. "clinic_diag=#{clinicDiagCode} where inpatient_no=#{bah} and admiss_times=#{times}")
  354. void updateZyInActPatient(@Param("bah") String bah, @Param("times") int times,
  355. @Param("autopsy") String autopsy,
  356. @Param("dc1") String dc1, @Param("dc2") String dc2,
  357. @Param("dc3") String dc3, @Param("dc4") String dc4,
  358. @Param("dc5") String dc5, @Param("hasSurgery") String hasSurgery,
  359. @Param("pathologicDiagStr") String pathologicDiagStr,
  360. @Param("pathologicDiagCode") String pathologicDiagCode,
  361. @Param("clinicDiagCode") String clinicDiagCode,
  362. @Param("clinicDiagStr") String clinicDiagStr);
  363. @Select("select count(1) from batj_ba1 with(nolock) where bah=#{bah} and zycs=#{times}")
  364. int isBatjBa1Exist(@Param("bah") String bah, @Param("times") int times);
  365. @Select("select count(1) from batj_ba2 with(nolock) where bah=#{bah} and zycs=#{times}")
  366. int isBatjBa2Exist(@Param("bah") String bah, @Param("times") int times);
  367. @Insert("insert into batj_ba1 (bah, zyh, zycs, xm, ryrq, ryks, rybf) values " +
  368. "(#{bah}, #{bah}, #{times}, #{name}, #{ryrq}, " +
  369. "(select code from zd_unit_code with(nolock) where name=#{dept}), " +
  370. "(select code from zd_unit_code with(nolock) where name=#{ward}))")
  371. void createBatjBa1(@Param("bah") String bah, @Param("times") int times,
  372. @Param("name") String name, @Param("ryrq") Date ryrq,
  373. @Param("dept") String dept, @Param("ward") String ward);
  374. @Insert("insert into batj_ba2 (bah, zyh, zycs) values (#{bah}, #{bah}, #{times})")
  375. void createBatjBa2(@Param("bah") String bah, @Param("times") int times);
  376. @Update("update batj_ba1 set " +
  377. "pay_method=#{payMethod}," +
  378. "age_days=#{ageDays}," +
  379. "jg=#{nativePlace}," +
  380. "new_born_weight=#{newBornWeight}," +
  381. "new_born_admiss_weight=#{newBornAdmissWeight}," +
  382. "xm=#{name}, " +
  383. "xb=#{sex}, " +
  384. "csrq=#{birthDate}, " +
  385. "hyzk=#{marriage}, " +
  386. "zy=#{occupation}, " +
  387. "csd=#{birthPlace}, " +
  388. "mz=#{nation}, " +
  389. "gj=#{country}, " +
  390. "sfzh=#{socialNo}, " +
  391. "gzdw=#{unitName}, " +
  392. "gzdh=#{unitPhone}, " +
  393. "gzyb=#{unitZipCode}, " +
  394. "hkdz=#{hkPlace}, " +
  395. "hkdz2=#{hkPlaceName}," +
  396. "hkyb=#{hkZipCode}, " +
  397. "lxr=#{contactName}, " +
  398. "lxrgx=#{contactRelation}, " +
  399. "lxdh=#{contactPhone}, " +
  400. "lxdz=#{contactAddr}, " +
  401. "lxdz2=#{contactAddrName}," +
  402. "rytj=#{zyAdmissWay}, " +
  403. "xzz=#{livePlace}, " +
  404. "xdh=#{phone} " +
  405. "where bah=#{bah} and zycs=#{admissTimes}")
  406. void updateBatjBa1(CaseFrontsheetMain info);
  407. @Update("update batj_ba2 set " +
  408. "blzd_qph=#{blh}," +
  409. "gm_flag=#{allergy}," +
  410. "gmwy=#{allergicMedicine}," +
  411. "hbsag=#{hbsAg}," +
  412. "hcv_vb=#{hcvAb}," +
  413. "hiv_vb=#{hivAb}," +
  414. "tp_ab=#{tpAb}," +
  415. "xx=#{bloodType}," +
  416. "xx_rh=#{rh}," +
  417. "kzr=#{deptLeader}," +
  418. "zrys=#{leaderDoctor}," +
  419. "zzys=#{mainDoctor}," +
  420. "zyys=#{admissDoctor}," +
  421. "job_nurse=#{dutyNurse}," +
  422. "jxys=#{studyDoctor}," +
  423. "sxys=#{internshipDoctor}," +
  424. "bmy=#{coder}," +
  425. "bazl=#{qualityControlLevel}," +
  426. "zkys=#{qualityControlDoctor}," +
  427. "zkhs=#{qualityControlNurse}," +
  428. "barq=#{qualityControlDate}," +
  429. "lyfs=#{zyDismissWay}," +
  430. "jsjg=#{dismissDestination}," +
  431. "zzy_flag=#{admissAgainInOneMonth}," +
  432. "zzy_md=#{admissAgainPurpose}," +
  433. "ryq_hmsj=#{comaDaysBeforeAdmiss}," +
  434. "ryh_hmsj=#{comaDaysAfterAdmiss}," +
  435. "qjcs=#{rescueTimes}," +
  436. "cgcs=#{rescueSuccessTimes}," +
  437. "blfx=#{caseClassification}," +
  438. "zzjh=#{hasIcu}," +
  439. "zzjh_day=#{icuDays}," +
  440. "zzjh_hour=#{icuHours}," +
  441. "dbz=#{monopathyManagement}," +
  442. "lclj=#{clinicalPathwayManagement}," +
  443. "drgs=#{drgsManagement}," +
  444. "kss=#{useAntibiotic}," +
  445. "xjpy=#{bacilliculture}," +
  446. "fdcrb=#{statutoryEpidemic}," +
  447. "hurt_reason_name=#{hurtReasonName}," +
  448. "hurt_reason_code=#{hurtReasonCode}," +
  449. "tumor_level_t=#{tumorLevelT}," +
  450. "tumor_level_n=#{tumorLevelN}," +
  451. "tumor_level_m=#{tumorLevelM}," +
  452. "apgar=#{xxeApgar} " +
  453. "where bah=#{bah} and zycs=#{admissTimes}")
  454. void updateBatjBa2(CaseFrontsheetMain info);
  455. @Delete("delete from ba_first_page1 where inpatient_no=#{bah} and admiss_times=#{times}")
  456. void deleteOldDisdiag(@Param("bah") String bah, @Param("times") int times);
  457. @Delete("delete from batj_ba4 where bah=#{bah} and zycs=#{times}")
  458. void deleteOldSurgeryRecord(@Param("bah") String bah, @Param("times") int times);
  459. @Insert("insert into ba_first_page1 (inpatient_no, admiss_times, dis_diag_no," +
  460. "dis_diag_comment, dis_diag, admiss_status, dis_diag_status, op_id_code) " +
  461. "values (#{bah}, #{times}, #{no}, #{name}, #{code}, #{admissStatus}, " +
  462. "#{dismissStatus}, #{opIdCode})")
  463. void writeNewDisdiag(CaseFrontsheetDisdiag disDiag);
  464. @Insert("insert into batj_ba4 (bah,zyh,zycs,ssxh,ssmc,ssrq,ssjb,ssbm,ssys,sszs1,sszs2,qkjb,yhqk," +
  465. "mzff,mzys,op_start_date,op_end_date,anst_start_date,anst_end_date) " +
  466. "values (#{bah},#{bah},#{times},#{no},#{name},#{date},#{level},#{code},#{operator},#{assistantOne}," +
  467. "#{assistantTwo},#{cut},#{heal},#{anaesthesia},#{anaesthesiaor},#{date},#{opEndDate},#{anstStartDate},#{anstEndDate})")
  468. void writeNewZySurgeryRecord(CaseFrontsheetSurgery surgery);
  469. @Update("update t_case_frontsheet_main set file_status=1, sign_date=getdate() where bah=#{bah} and admiss_times=#{times}")
  470. void updateSignStatus(@Param("bah") String bah, @Param("times") int times);
  471. @Insert("insert into ba_op_log (op_type, op_id, op_time, inpatient_no, admiss_times) values " +
  472. "(#{opType}, #{staffId}, getDate(), #{bah}, #{admissTimes})")
  473. void writeBaOpLog(@Param("opType") int opType,
  474. @Param("staffId") String staffId,
  475. @Param("bah") String bah,
  476. @Param("admissTimes") int admissTimes);
  477. @Select("select rtrim(dis_diag_no) no, rtrim(dis_diag) code, " +
  478. "rtrim(dis_diag_comment) name, rtrim(dis_diag_status) cyzg, " +
  479. "rtrim(op_id_code) operId, convert(varchar(19), op_diag_date, 21) opDate, " +
  480. "diagType='13',si_diag_type,bzfx='普通', admiss_cond " +
  481. "from zy_dis_diag_yb with(nolock) where inpatient_no=#{bah} and admiss_times=#{times}")
  482. List<YiBaoDisdiag> getYbDiags(@Param("bah") String bah, @Param("times") int times);
  483. @Delete("delete from zy_dis_diag_yb where inpatient_no=#{bah} and admiss_times=#{times}")
  484. void deleteOldYbDiag(@Param("bah") String bah, @Param("times") int times);
  485. @Insert("insert into zy_dis_diag_yb (inpatient_no, admiss_times, dis_diag_no, dis_diag_type, dis_diag, " +
  486. "dis_diag_comment, op_id_code, op_diag_date, dis_diag_bzfx, dis_diag_status, si_diag_type, admiss_cond) " +
  487. "values (#{bah},#{times},#{no},13,#{code},#{name},#{operId},#{opDate},'普通',#{cyzg},#{siDiagType},#{admissCond}) ")
  488. void insertNewYbDiag(YiBaoDisdiag diag);
  489. @Select("select count(1) from zy_inactpatient a with(nolock), batj_ba2 b with(nolock) " +
  490. "where (dis_dept=#{ward} or dis_ward=#{ward}) and " +
  491. "b.bah=a.inpatient_no and " +
  492. "b.zycs=a.admiss_times and " +
  493. "b.blfx>2")
  494. Integer getCDBlfxCount(@Param("ward") String ward);
  495. @Select("select count(1) from zy_inactpatient with(nolock) where dis_dept=#{ward} or dis_ward=#{ward}")
  496. Integer getAllDisPatientCount(@Param("ward") String ward);
  497. @Select("<script>" +
  498. "select distinct " +
  499. "a.bah,a.admiss_times as times, " +
  500. "a.name,a.sex,fileStatus=1, " +
  501. "a.admiss_doctor_name as doctorName, " +
  502. "a.sign_date, " +
  503. "a.dismiss_date," +
  504. "a.admiss_dept, " +
  505. "a.dismiss_dept, " +
  506. "a.case_classification as blfx " +
  507. "from t_case_frontsheet_main a with(nolock), " +
  508. "t_case_frontsheet_disdiag c with(nolock), " +
  509. "t_case_frontsheet_surgery d with(nolock) " +
  510. "where " +
  511. "a.dismiss_date&gt;=#{start} and " +
  512. "a.dismiss_date&lt;=#{end} and " +
  513. "<if test=\"blfxChkbox!=null and blfxChkbox.size>0 \">" +
  514. "a.case_classification in " +
  515. "<foreach collection='blfxChkbox' item='item' open='(' close=')' separator=','>" +
  516. "#{item}" +
  517. "</foreach> and " +
  518. "</if>" +
  519. "<if test=\"medType!=null and medType!='' \">" +
  520. "a.med_type=#{medType} and " +
  521. "</if>" +
  522. "<if test=\"doctorCode!=null and doctorCode!='' \">" +
  523. "a.admiss_doctor=#{doctorCode} and " +
  524. "</if>" +
  525. "<if test=\"sex!=null and sex!='' \">" +
  526. "a.sex=#{sex} and " +
  527. "</if>" +
  528. "<if test=\"icdCode!=null and icdCode!='' \">" +
  529. "c.code=#{icdCode} and " +
  530. "</if>" +
  531. "<if test=\"surgeryCode!=null and surgeryCode!='' \">" +
  532. "d.code=#{surgeryCode} and " +
  533. "</if>" +
  534. "c.bah=a.bah and " +
  535. "c.times=a.admiss_times and " +
  536. "d.bah=a.bah and " +
  537. "d.times=a.admiss_times " +
  538. "</script>")
  539. List<SheetOverview> advanceSearch(AdvanceSearchParam param);
  540. @Select("select file_status from t_case_frontsheet_main with(nolock) where bah=#{bah} and admiss_times=#{admissTimes}")
  541. Integer selectFileStatus(@Param("bah") String bah,
  542. @Param("admissTimes") Integer admissTimes);
  543. @Select("select rtrim(dept_code) from a_employee_mi where code=#{code}")
  544. String selectUserDept(@Param("code") String code);
  545. @Select("select count(1) from t_yb_setl_modify_req where pat_no=#{bah} and times=#{times}")
  546. Integer selectModified(@Param("bah") String bah, @Param("times") Integer times);
  547. @Select("select top 1 * from t_si_disefamily_diagnose with(nolock) where dise_code=#{code} ")
  548. DisefamilyGrade selectDisefamilyGrade(@Param("code") String code);
  549. @Select("select yb_code from zd_icd9_cm3 where code in " +
  550. "(select ssbm from ${table} with(nolock) where zyh=#{bah} and zycs=#{times} and isnull(ssbm,'')!='') " +
  551. "union select ssbm from ${table} with(nolock) where zyh=#{bah} and zycs=#{times} and isnull(ssbm,'')!=''")
  552. List<String> selectPatientSurgeryCodes(@Param("bah") String bah, @Param("times") Integer times, @Param("table") String table);
  553. @Select("select * from t_si_operation_disefamily with(nolock) where disefamily_code=#{code}")
  554. List<OprnDisefamilyGrade> selectOperationDisefamilies(@Param("code") String code);
  555. @Update("update zd_icd_code set weight=(weight+1) where code=#{code}")
  556. void increaseDiagWeight(@Param("code") String code);
  557. @Select("select * from t_case_frontsheet_main where bah=#{bah} and admiss_times=#{times}")
  558. CaseFrontsheetMain selectSignedSheetMain(@Param("bah") String bah, @Param("times") Integer times);
  559. @Select("select * from t_case_frontsheet_disdiag where bah=#{bah} and times=#{times} ")
  560. List<CaseFrontsheetDisdiag> selectSignedSheetDiags(@Param("bah") String bah, @Param("times") Integer times);
  561. @Select("select * from t_case_frontsheet_surgery where bah=#{bah} and times=#{times} ")
  562. List<CaseFrontsheetSurgery> selectSignedSheetSurgeries(@Param("bah") String bah, @Param("times") Integer times);
  563. @Update("update t_case_frontsheet_main set age_days=#{agedays} where bah=#{bah} and admiss_times=#{times}")
  564. void updateNewBornAge(@Param("bah") String bah, @Param("times") Integer times, @Param("agedays") Integer agedays);
  565. @Select("select rtrim(yb_code) as code, rtrim(yb_name) as name from zd_icd_code_new where code=#{code} and del_flag=0")
  566. CodeName selectSiDiagByBaDiag(@Param("code") String code);
  567. @Select("select province_code,city_code,district_code," +
  568. "provinceName=(select name from t_region where code=province_code), " +
  569. "cityName=(select name from t_region where code=city_code), " +
  570. "districtName=(select name from t_region where code=district_code) " +
  571. "from a_patient_mi where inpatient_no=#{bah}")
  572. StandardAddressMember selectStandardAddressMember(@Param("bah") String bah);
  573. @Select("select rtrim(social_no) from a_patient_mi where inpatient_no=#{bah}")
  574. String selectSocialNo(@Param("bah") String bah);
  575. @Select("select parent_code as code, name=(select t.name from t_region t where t.code=a.parent_code) " +
  576. "from t_region a where code=#{region}")
  577. Region selectParentRegion(@Param("region") Integer region);
  578. @Select("select name from t_region where code=#{region}")
  579. String selectRegionName(@Param("region") Integer region);
  580. @Select("select top 1 med_type from t_si_pat_info where pat_no=#{patNo} and times=#{times} order by " +
  581. "ledger_sn desc")
  582. String selectMedType(@Param("patNo") String patNo,
  583. @Param("times") int times);
  584. @Select("select provinceName=(select name from t_region where code=#{province}), " +
  585. "cityName=(select name from t_region where code=#{city}), " +
  586. "districtName=(select name from t_region where code=#{district}) ")
  587. StandardAddressMember selectStandardAddressMember2(@Param("province") int province,
  588. @Param("city") int city,
  589. @Param("district") int district);
  590. @Select("select audit_flag from t_yb_setl_modify_req where pat_no=#{patNo} and times=#{times} ")
  591. Integer qualityPass(@Param("patNo") String patNo, @Param("times") Integer times);
  592. @Select("<script>" +
  593. "select rtrim(code) as code,rtrim(name) as name,charge_code as wjwCode,charge_name as wjwName from zd_icd9_cm3 " +
  594. "where code in " +
  595. "<foreach collection='surgeries' item='surgery' open='(' separator=',' close=')'>" +
  596. "#{surgery.code}" +
  597. "</foreach>" +
  598. "</script>")
  599. List<HisWjwMatchEntity> selectSurgeryChargeCode(List<CaseFrontsheetSurgery> surgeries);
  600. @Select("<script>" +
  601. "select sum(charge_amount) from zy_detail_charge where inpatient_no=#{patNo} and admiss_times=#{times} " +
  602. "and charge_code_mx in " +
  603. "<foreach collection='list' item='code' open='(' separator=',' close=')'>" +
  604. "#{code}" +
  605. "</foreach>" +
  606. "</script>")
  607. Integer selectChargeSumamt(@Param("patNo") String patNo, @Param("times") int times, @Param("list") String[] list);
  608. @Select("select code,yb_name as name,yb_code from zd_anaesthesia where yb_code is not null")
  609. List<CodeName> selectZdAnstWays();
  610. @Select("select code,rtrim(name) as name,si_code as ybCode from zd_country_code where si_code is not null")
  611. List<CodeName> selectZdCountries();
  612. @Select("select code,rtrim(name) as name,code2 as ybCode from zd_nation_code where code2 is not null ")
  613. List<CodeName> selectZdNations();
  614. @Select("select top 1 insuplc_admdvs from t_si_setlinfo where pat_no=#{patNo} and times=#{times} and revoked=0")
  615. String selectSetlInsuplcAdmdvs(@Param("patNo") String patNo, @Param("times") int times);
  616. @Select("select top 1 isnull(op_type,9) from zd_icd9_cm3 where code=#{code}")
  617. Integer selectOperationType(@Param("code") String code);
  618. // 病历分型
  619. @Select("select data_element from emr_data_element where pat_no=#{patNo} and times=#{times}")
  620. String selectBlfxElement(String patNo, int times);
  621. // 细菌培养次数
  622. @Select("select count(1) from ysh_yj_req where inpatient_no=#{patNo} and admiss_times=#{times} " +
  623. "and req_type=2 and order_type='011'")
  624. int selectBacillicultureCount(String patNo, int times);
  625. // 法定传染病
  626. @Select("SELECT rtrim(contagion) as a,rtrim(contagion2) as b,rtrim(contagion3) as c " +
  627. "FROM crb_main_card where patient_id=#{patNo} and times=#{times}")
  628. Map<String, String> selectStatutoryEpidemic(String patNo, int times);
  629. // 抗生素使用次数
  630. @Select("select count(1) from zy_detail_charge a left join yp_zd_dict b on (code=charge_code_mx " +
  631. "and b.serial='01') where a.serial!='00' and ori_detail_sn is null and trans_flag_yb!='2' " +
  632. "and kss_flag='1' and inpatient_no=#{patNo} and admiss_times=#{times}")
  633. int selectAntibiotics(String patNo, int times);
  634. }