SurgeryArrangementDao.java 6.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package thyyxxk.webserver.dao.his.surgicalmanagement;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.toolkit.Constants;
  4. import org.apache.ibatis.annotations.Mapper;
  5. import org.apache.ibatis.annotations.Param;
  6. import org.apache.ibatis.annotations.Select;
  7. import org.apache.ibatis.annotations.Update;
  8. import thyyxxk.webserver.entity.dictionary.CodeName;
  9. import thyyxxk.webserver.entity.zhuyuanyisheng.shoushu.OpRecord;
  10. import java.util.Date;
  11. import java.util.List;
  12. @Mapper
  13. public interface SurgeryArrangementDao {
  14. @Select("select rtrim(ward_code) as code, rtrim(ward_name) as name from zy_adtward")
  15. List<CodeName> getAllSurgicalWard();
  16. @Select("select code,name,status_flag from op_zd_room")
  17. List<CodeName> selectSurgeryRooms();
  18. @Select("select code='',name='' union " +
  19. "select rtrim(code) as code,rtrim(name) as name from a_employee_mi " +
  20. "where dept_code=#{deptCode} and isnull(del_flag,0)!=1")
  21. List<CodeName> selectStaffsByDeptCode(String deptCode);
  22. @Select("select a.record_id,op_start_date,op_end_date,anst_start_date,anst_end_date,a.sstc,a.req_date, " +
  23. "a.zy_serial_no,a.op_times,a.patient_name,a.dept_code,a.ward_code,a.apply_date,a.apply_user,a.apply_doc, " +
  24. "a.schedule_date,a.schedule_user,a.status,a.patient_type,a.act_order_no,a.op_code,a.op_name,a.op_datetime, " +
  25. "a.room_code,room_name=(select rtrim(d.name) from op_zd_room d where d.code=a.room_code),a.op_group_code, " +
  26. "a.hocus_code,hocus_name=(select rtrim(d.name) from zd_anaesthesia d where d.code=a.hocus_code), " +
  27. "a.diag_before_op,a.diag_after_op,a.infection_flag,a.urgent_clinic_flag,a.avocation_flag,a.blood_amount, " +
  28. "a.blood_type,a.op_stastics_id,a.isolation_indicator,a.op_scale,a.op_endtime,a.diag_before_code, " +
  29. "a.diag_after_code,a.hbsag,a.body_code,a.part_code,a.specialreq_code,a.instrument_code,a.aspesis_scale, " +
  30. "a.remark,a.op_dept,a.input_id,a.input_date,a.req_id,a.req_date,a.last_modify_id,a.arrange_id, " +
  31. "a.arrange_date,a.inpatient_no,a.admiss_times,a.cancel_id,a.cancel_time,b.doctor_zd,b.doctor_mz, " +
  32. "b.doctor_1,b.doctor_2,b.nurse_xh,b.nurse_qx,a.bed_no,a.arrangement_executed, " +
  33. "chargeSum=(select sum(d.charge_amount) from zy_detail_charge d where " +
  34. "d.inpatient_no=a.inpatient_no and d.ss_code=a.record_id), " +
  35. "sex=case when c.sex='1' then '男' else '女' end, " +
  36. "age=case when c.birth_date is null then '' " +
  37. "when datediff(year, c.birth_date, a.op_datetime) > 14 then " +
  38. "convert(varchar(2), datediff(year, c.birth_date, a.op_datetime)) + '岁' " +
  39. "when datediff(dd, c.birth_date, a.op_datetime) >= 365 then " +
  40. "convert(varchar(2), datediff(dd, c.birth_date, a.op_datetime) / 365) + '岁' + " +
  41. "convert(varchar(2), ((datediff(dd, c.birth_date, a.op_datetime) / 30) % 12)) + '月' " +
  42. "when datediff(dd, c.birth_date, a.op_datetime) < 30 then " +
  43. "convert(varchar(2), case datediff(dd, c.birth_date, a.op_datetime) " +
  44. "when 0 then 1 else datediff(dd, c.birth_date, a.op_datetime) end) + '天' " +
  45. "else convert(varchar(2), datediff(dd, c.birth_date, a.op_datetime) / 30) + '月' " +
  46. "end, " +
  47. "a.tw_flag,b.doctor_mz_ys,b.doctor_mz_hs,rtrim(a.ssbc) as ssbc,b.doctor_zd_sj, " +
  48. "a.preoperative_visit,a.preoperative_preparation " +
  49. "FROM op_record a,op_record_join b,a_patient_mi c " +
  50. "where a.record_id=b.record_id and a.inpatient_no=c.inpatient_no and " +
  51. " ${ew.sqlSegment} order by a.urgent_clinic_flag desc, a.room_code")
  52. List<OpRecord> selectSurgeryArrangements(@Param(Constants.WRAPPER) QueryWrapper<?> queryWrapper);
  53. @Update("update op_record set status=#{status} where record_id=#{recordId}")
  54. void updateSurgeryStatus(Integer recordId, String status);
  55. @Update("update ${table} set ${column}=#{value} where record_id=#{id}")
  56. void updateArrangement(String table, String column, String value, Integer id);
  57. @Select("select count(1) from dj_user_role where user_code=#{code} and role_id=51")
  58. Integer selectArrangementPermission(String code);
  59. @Select("select rtrim(code_rs) from a_employee_mi where code in (#{code1},#{code2})")
  60. List<String> selectCodeRsList(String code1, String code2);
  61. @Select("select name from op_zd_room where code=#{code}")
  62. String selectRoomName(String code);
  63. @Select("select a.record_id,a.patient_name,a.dept_code,a.op_scale,a.urgent_clinic_flag, " +
  64. "deptName=(select rtrim(d.name) from zd_unit_code d where d.code=a.dept_code), " +
  65. "a.apply_date,a.inpatient_no,a.admiss_times,b.doctor_zd,b.doctor_mz,b.nurse_qx,b.nurse_xh, " +
  66. "doctorZdName=(select rtrim(d.name) from a_employee_mi d where d.code=b.doctor_zd), " +
  67. "doctor1Name=(select rtrim(d.name) from a_employee_mi d where d.code=b.doctor_1), " +
  68. "doctor2Name=(select rtrim(d.name) from a_employee_mi d where d.code=b.doctor_2), " +
  69. "doctorMzName=(select rtrim(d.name) from a_employee_mi d where d.code=b.doctor_mz), " +
  70. "nurseXhName=(select rtrim(d.name) from a_employee_mi d where d.code=b.nurse_xh), " +
  71. "nurseQxName=(select rtrim(d.name) from a_employee_mi d where d.code=b.nurse_qx), " +
  72. "applyDocName=(select rtrim(d.name) from a_employee_mi d where d.code=a.apply_doc), " +
  73. "a.status,a.patient_type,a.op_code,a.op_name,a.op_datetime,a.hocus_code, " +
  74. "hocusName=(select rtrim(d.name) from zd_anaesthesia d where d.code=a.hocus_code) " +
  75. "from op_record a,op_record_join b " +
  76. "where a.op_datetime>=#{start} and a.op_datetime<=#{end} and a.record_id=b.record_id " +
  77. "and cast(a.room_code as int)<15 and a.status!='d' " +
  78. "order by a.op_datetime")
  79. List<OpRecord> selectOpRecordStatistics(Date start, Date end);
  80. }