ShouShuShenQingDao.java 16 KB

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