CaseFrontSheetDao.java 38 KB

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