ShouShuShenQingDao.java 16 KB

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