ShouShuShenQingDao.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. package thyyxxk.webserver.dao.his.zhuyuanyisheng;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.baomidou.mybatisplus.core.toolkit.Constants;
  6. import org.apache.ibatis.annotations.*;
  7. import org.aspectj.apache.bcel.classfile.Code;
  8. import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
  9. import thyyxxk.webserver.entity.dictionary.CodeName;
  10. import thyyxxk.webserver.entity.zhuyuanyisheng.shoushu.OpRecord;
  11. import thyyxxk.webserver.entity.zhuyuanyisheng.shoushu.ShouShuFanHui;
  12. import thyyxxk.webserver.entity.zhuyuanyisheng.shoushu.TReqSurgicalDiag;
  13. import thyyxxk.webserver.entity.zhuyuanyisheng.shoushu.ZdIcd9Cm3;
  14. import thyyxxk.webserver.entity.zhuyuanyisheng.yizhuluru.XinZhenYiZhu;
  15. import java.math.BigDecimal;
  16. import java.util.List;
  17. import java.util.Map;
  18. /**
  19. * <p>
  20. * 描述: 手术申请
  21. * </p>
  22. *
  23. * @author xc
  24. * @date 2022-02-22 15:45
  25. */
  26. @Mapper
  27. public interface ShouShuShenQingDao extends BaseMapper<OpRecord> {
  28. @Select("<script>" +
  29. "select op_type_name = (select name from zd_operation_type where code = op_type), " +
  30. " rtrim(yb_code) as code," +
  31. " rtrim(yb_name) name,op_scale " +
  32. "from zd_icd9_cm3 " +
  33. "where (code like #{name} or name like #{name} or py_code like #{name} or d_code like #{name}) " +
  34. "<if test=\"type !=null and type != 0 \">" +
  35. " and op_type = #{type} " +
  36. "</if>" +
  37. "</script>")
  38. List<ZdIcd9Cm3> obtainSurgicalItems(String name,
  39. Integer type);
  40. @Select("select code as code,name_doctor as name from op_level_management where code_op = #{code} ")
  41. List<CodeName> getDoctorByOpCode(String code);
  42. @Select("select rtrim(op_name) as value " +
  43. "from op_record with (NOLOCK) " +
  44. "where inpatient_no = #{patNo} " +
  45. " and admiss_times = #{times}" +
  46. " and op_name like #{name} ")
  47. List<Map<String, String>> huoQuShouShuMing(@Param("patNo") String patNo,
  48. @Param("times") Integer times,
  49. @Param("name") String name);
  50. @Select("select count(1) from op_record where inpatient_no = #{patNo} and admiss_times = #{times} and status <> 'd' ")
  51. int currentPatientOpCount(String patNo, Integer times);
  52. @Select("select count(1) from emr_patient_data where pat_no = #{patNo} and times = #{times} and del_flag = 0 and emr_category_code = 'shuqiantaolun' ")
  53. int currentEmrPreoperativelyDiscussCount(String patNo, Integer times);
  54. @Select("SELECT a.code, a.name " +
  55. "FROM ysh_zd_ss_type a with (NOLOCK), " +
  56. " yz_order_item b with (NOLOCK) " +
  57. "where a.code = b.ss_type " +
  58. " and isnull(b.del_flag, '') <> '1' " +
  59. " and b.operation = 'p' " +
  60. "group by a.code, a.name " +
  61. "order by a.name")
  62. List<GetDropdownBox> shouShuShenQingCeBianLan();
  63. @Select("select a.record_id /*申请单号*/," +
  64. " a.op_name," +
  65. " a.urgent_clinic_flag," +
  66. " a.apply_date, " +
  67. " part_code," +
  68. " partCodeName = (select rtrim(name) from op_zd_part_new where code = part_code), " +
  69. " dept_code, " +
  70. " dept_code_name = (select rtrim(name) from zd_unit_code with (NOLOCK) where code = dept_code), " +
  71. " urgent_clinic_flag, " +
  72. " inpatient_no, " +
  73. " admiss_times, " +
  74. " bed_no, " +
  75. " patient_name, " +
  76. " diag_before_op /* 术前诊断 */, " +
  77. " diag_before_code, " +
  78. " hocus_code, " +
  79. " hocusName = (select rtrim(name) from zd_anaesthesia with (NOLOCK) where code = hocus_code), " +
  80. " op_scale, " +
  81. " doctor_zd_name = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = doctor_zd)/*主刀医生*/, " +
  82. " doctor_1_name = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = doctor_1)/*第1助手*/, " +
  83. " doctor_2_name = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = doctor_2)/*第2助手*/, " +
  84. " doctor_3_name = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = doctor_3)/*第2助手*/, " +
  85. " doctor_mz_name = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = doctor_mz)/*麻醉医生*/, " +
  86. " nurse_qx_name = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = nurse_qx)/*器械护士*/, " +
  87. " nurse_xh_name = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = nurse_xh)/*巡回护士*/, " +
  88. " req_date, " +
  89. " op_datetime, " +
  90. " remark/*附注说明*/ " +
  91. "from op_record a with (NOLOCK), " +
  92. " op_record_join b with (NOLOCK)" +
  93. "where inpatient_no = #{patNo} " +
  94. " and admiss_times = #{times} " +
  95. " and a.record_id = #{recordId} " +
  96. " and a.record_id = b.record_id")
  97. OpRecord daYingShouShu(@Param("patNo") String patNo,
  98. @Param("times") Integer times,
  99. @Param("recordId") Integer recordId);
  100. @Select("select req_no, code, name, type, sort " +
  101. "from t_req_surgical_diag where req_no = #{recordId}")
  102. List<TReqSurgicalDiag> selectReqSurgicalDiagByReqNo(@Param("recordId") Integer recordId);
  103. @Select("select refer_physician_name = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = refer_physician) /*住院医生*/, " +
  104. " dept_director_name = (select rtrim(name) from a_employee_mi with (NOLOCK) where code = dept_director) /*科主任*/, " +
  105. " sex, " +
  106. " birth_date = (select (convert(varchar(10), birth_date, 21)) " +
  107. " from a_patient_mi with (NOLOCK) " +
  108. " where zy_actpatient.inpatient_no = a_patient_mi.inpatient_no) " +
  109. "from zy_actpatient with (NOLOCK) " +
  110. "where inpatient_no = #{patNo} " +
  111. " and admiss_times = #{times};")
  112. OpRecord daYingHuanZheXinXi(@Param("patNo") String patNo,
  113. @Param("times") Integer times);
  114. @Select("<script>" +
  115. "SELECT rtrim(order_code) as opCode, " +
  116. " rtrim(order_name) as opName, " +
  117. " rtrim(ss_type) as orderType " +
  118. "FROM yz_order_item with (NOLOCK) " +
  119. "where operation = 'p' " +
  120. "<if test=\"code != null and code != '' \">" +
  121. " and ss_type = #{code} " +
  122. "</if>" +
  123. " and isnull(del_flag, '') &lt;&gt; '1' " +
  124. " and (order_name like #{name} or order_code like #{name} or py_code like #{name} or d_code like #{name})" +
  125. "</script>")
  126. IPage<ShouShuFanHui> fenLeiXiangQing(IPage<ShouShuFanHui> page,
  127. @Param("code") String code,
  128. @Param("name") String name);
  129. @Select("<script>" +
  130. "select code,name, py_code, d_code as w_code from op_zd_part_new " +
  131. "with (NOLOCK) where 1=1 " +
  132. "<if test=\"code != null and code != '' \">" +
  133. "(name like #{code} or py_code like #{code} or d_code like #{code} or code like #{code})" +
  134. "</if>" +
  135. "</script>")
  136. List<GetDropdownBox> huoQuShouShuBuWei(String code);
  137. @Select("Select isnull(Max(op_times),0) " +
  138. "From op_record with (NOLOCK) " +
  139. "Where inpatient_no = #{patNo} " +
  140. " And admiss_times = #{times} ")
  141. Integer shouShuShenQingCiShu(@Param("patNo") String patNo,
  142. @Param("times") Integer times);
  143. @Insert("<script>" +
  144. "Insert Into op_record_join (record_id, zy_serial_no, op_times, doctor_zd, doctor_wp, doctor_1, doctor_2, doctor_3,nurse_qx, nurse_xh,doctor_mz_ys) " +
  145. "Values " +
  146. "<foreach collection='list' item='item' separator=','>" +
  147. "(#{item.recordId}, '', #{item.opTimes}, #{item.doctorZd}, null, #{item.doctor1}, #{item.doctor2}, " +
  148. "#{item.doctor3}, #{item.nurseQx}, #{item.nurseXh},#{item.doctorMzYs})" +
  149. "</foreach>" +
  150. "</script>")
  151. void chaRuShouShuYiSheng(@Param("list") List<OpRecord> list);
  152. @Insert("Insert Into op_record_join (record_id, zy_serial_no, op_times, doctor_zd, doctor_wp, doctor_1, doctor_2, " +
  153. "doctor_3,nurse_qx, nurse_xh,doctor_mz_ys) " +
  154. "Values " +
  155. "(#{item.recordId}, '', #{item.opTimes}, #{item.doctorZd}, null, #{item.doctor1}, #{item.doctor2}, " +
  156. "#{item.doctor3}, #{item.nurseQx}, #{item.nurseXh},#{item.doctorMzYs})")
  157. void insertOpRecordJoin(@Param("item") OpRecord item);
  158. @Insert("<script>" +
  159. "INSERT INTO op_record (record_id, inpatient_no, patient_name, admiss_times, op_times, dept_code, ward_code, op_code, " +
  160. " op_datetime, infection_flag, urgent_clinic_flag, isolation_indicator, op_scale, input_id, status, " +
  161. " input_date, apply_date, apply_doc, op_name, act_order_no, patient_type, req_date, req_id, bed_no, " +
  162. " ssbc, ssyz_flag, ward_dept,remark,hocus_code,diag_before_op,diag_before_code," +
  163. " part_code) " +
  164. " VALUES " +
  165. "<foreach collection='list' item='item' separator=','>" +
  166. " (#{item.recordId}, #{patNo}, #{name}, #{times}, #{item.opTimes}, #{dept}, #{ward}, #{item.opCode}, " +
  167. " #{item.opDatetime}, '0', #{item.urgentClinicFlag}, '0', #{item.opScale}, " +
  168. " #{userCode}, '1', getdate(), #{item.applyDate}, #{userCode}, #{item.opName}, #{item.actOrderNo}, '2', " +
  169. " getdate(), #{userCode}, #{bedNo}, #{item.ssbc}, #{item.ssyzFlag}, #{admissWard},#{item.remark},#{item.hocusCode}," +
  170. "#{item.diagBeforeOp},#{item.diagBeforeCode}," +
  171. " #{item.partCode})" +
  172. "</foreach>" +
  173. "</script>")
  174. void chaRuShouShu(@Param("list") List<OpRecord> list,
  175. @Param("patNo") String patNo,
  176. @Param("name") String name,
  177. @Param("times") Integer times,
  178. @Param("dept") String dept,
  179. @Param("ward") String ward,
  180. @Param("userCode") String userCode,
  181. @Param("bedNo") String bedNo,
  182. @Param("admissWard") String admissWard);
  183. @Insert("INSERT INTO op_record (record_id, inpatient_no, patient_name, admiss_times, op_times, dept_code, ward_code, op_code, " +
  184. " op_datetime, infection_flag, urgent_clinic_flag, isolation_indicator, op_scale, input_id, status, " +
  185. " input_date, apply_date, apply_doc, op_name, act_order_no, patient_type, req_date, req_id, bed_no, " +
  186. " ssbc, ssyz_flag, ward_dept,remark,hocus_code,diag_before_op,diag_before_code," +
  187. " part_code) " +
  188. " VALUES " +
  189. " (#{item.recordId}, #{patNo}, #{name}, #{times}, #{item.opTimes}, #{dept}, #{ward}, #{item.opCode}, " +
  190. " #{item.opDatetime}, '0', #{item.urgentClinicFlag}, '0', #{item.opScale}, " +
  191. " #{userCode}, '1', getdate(), #{item.applyDate}, #{userCode}, #{item.opName}, #{item.actOrderNo}, '2', " +
  192. " getdate(), #{userCode}, #{bedNo}, #{item.ssbc}, #{item.ssyzFlag}, #{admissWard},#{item.remark},#{item.hocusCode}," +
  193. "#{item.diagBeforeOp},#{item.diagBeforeCode}," +
  194. "#{item.partCode})")
  195. void insertOpRecord(@Param("item") OpRecord item,
  196. @Param("patNo") String patNo,
  197. @Param("name") String name,
  198. @Param("times") Integer times,
  199. @Param("dept") String dept,
  200. @Param("ward") String ward,
  201. @Param("userCode") String userCode,
  202. @Param("bedNo") String bedNo,
  203. @Param("admissWard") String admissWard);
  204. @Insert("<script>" +
  205. "INSERT INTO yz_act_order (order_code, order_name, frequ_code, infant_flag, order_time, physician, start_time, " +
  206. " act_order_no, inpatient_no, admiss_times, drug_flag, enter_oper, enter_time, status_flag, " +
  207. " signer, confirm_time, " +
  208. " self_buy, pay_self, serial, group_no, doctor_flag, dept_code, ward_code, reg_flag," +
  209. "yb_self_flag,emergency_flag,exec_unit) " +
  210. " VALUES " +
  211. "<foreach collection='list' item='item' separator=','>" +
  212. " ('${yzCode}', '${item.orderName}', 'ONCE', #{p.infantFlag}, getdate(), #{userCode}, getdate(), " +
  213. " #{item.actOrderNo}, #{p.inpatientNo}, " +
  214. " #{p.admissTimes}, 'p', #{userCode}, getdate(), '1', #{userCode}, getdate(), '0', '0', '00', '00', '1', #{p.deptCode}, #{p.deptCode}," +
  215. "'1',#{item.ybSelfFlag},#{item.urgentClinicFlag},#{execUnit})" +
  216. "</foreach>" +
  217. "</script>")
  218. void chaRuYiZhu(@Param("list") List<OpRecord> list,
  219. @Param("p") XinZhenYiZhu p,
  220. @Param("userCode") String userCode,
  221. @Param("execUnit") String execUnit,
  222. @Param("yzCode") String yzCode);
  223. @Insert("INSERT INTO yz_act_order (order_code, order_name, frequ_code, infant_flag, order_time, physician, start_time, " +
  224. " act_order_no, inpatient_no, admiss_times, drug_flag, enter_oper, enter_time, status_flag, " +
  225. " signer, confirm_time, " +
  226. " self_buy, pay_self, serial, group_no, doctor_flag, dept_code, ward_code, reg_flag," +
  227. "yb_self_flag,emergency_flag,exec_unit) " +
  228. " VALUES " +
  229. " ('${yzCode}', '${item.orderName}', 'ONCE', #{p.infantFlag}, getdate(), #{userCode}, getdate(), " +
  230. " #{item.actOrderNo}, #{p.inpatientNo}, " +
  231. " #{p.admissTimes}, 'p', #{userCode}, getdate(), '1', #{userCode}, getdate(), '0', '0', '00', '00', '1'," +
  232. " #{p.deptCode}, #{p.deptCode}," +
  233. "'1',#{item.ybSelfFlag},#{item.urgentClinicFlag},#{execUnit})")
  234. void insertYzOrderData(@Param("item") OpRecord item,
  235. @Param("p") XinZhenYiZhu p,
  236. @Param("userCode") String userCode,
  237. @Param("execUnit") String execUnit,
  238. @Param("yzCode") String yzCode);
  239. @Delete("delete op_record where record_id = #{reqNo};" +
  240. "delete op_record_join where record_id = #{reqNo};" +
  241. "delete yz_act_order where act_order_no = #{orderNo}")
  242. void delOpRecord(Integer reqNo, BigDecimal orderNo);
  243. @Select("select * from op_record with (NOLOCK) where record_id = #{id}")
  244. OpRecord shouShuXinXi(Integer id);
  245. @Update("update op_record set status = 'd' where record_id = #{id}")
  246. void genXingShanChuBiaoZhi(Integer id);
  247. @Select("select count(1) from op_zd_part where name = #{name} and del_flag = 0")
  248. Boolean repeatPartName(String name);
  249. @Select("select cast(max(code) as INTEGER) as code from op_zd_part")
  250. Integer getTheMaximumSurgicalCode();
  251. @Insert("insert into op_zd_part (code, name, py_code, d_code) " +
  252. "values (#{code}, #{name}, #{py}, #{wb})")
  253. void insertNewSurgicalSite(@Param("code") String code,
  254. @Param("name") String name,
  255. @Param("py") String py,
  256. @Param("wb") String wb);
  257. @Update("update op_zd_part set del_flag = 1 where code = #{code}")
  258. void removeSurgicalSite(String code);
  259. @Select("select op_name,\n" +
  260. " op_datetime,\n" +
  261. " status,\n" +
  262. " a.record_id,\n" +
  263. " diag_before_op,\n" +
  264. " b.doctor_zd,\n" +
  265. " doctor_zd_name = (select rtrim(name) from a_employee_mi where code = b.doctor_zd),\n" +
  266. " b.doctor_1,\n" +
  267. " doctor_1_name = (select rtrim(name) from a_employee_mi where code = doctor_1),\n" +
  268. " hocus_code,\n" +
  269. " hocusName = (select rtrim(name) from zd_anaesthesia where hocus_code = code)\n," +
  270. " inpatient_no, admiss_times,urgent_clinic_flag " +
  271. "from op_record a\n" +
  272. " left join op_record_join b on (a.record_id = b.record_id) ${ew.customSqlSegment} ")
  273. List<OpRecord> selectOpRecord(@Param(Constants.WRAPPER) QueryWrapper<OpRecord> queryWrapper);
  274. @Insert("<script>" +
  275. "insert into t_req_surgical_diag (req_no, code, name, type, sort) values " +
  276. "<foreach collection='list' item='item' index='index' separator=','>" +
  277. "(#{item.reqNo},#{item.code},#{item.name},#{item.type},#{item.sort})" +
  278. "</foreach>" +
  279. "</script>")
  280. void insertReqSurgicalDiag(@Param("list") List<TReqSurgicalDiag> list);
  281. }