BizClinicRoomMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="cn.tr.module.smart.common.repository.BizClinicRoomRepository">
  6. <resultMap id="stdWxAppletDetailResult" type="cn.tr.module.smart.wx.controller.vo.BizWxAppletClinicDetailVO">
  7. <result property="id" column="id"/>
  8. <result property="patientName" column="patient_name"/>
  9. <result property="patientAge" column="patient_age"/>
  10. <result property="patientGender" column="patient_gender"/>
  11. <result property="patientCode" column="patient_code"/>
  12. <result property="clinicStartTime" column="clinic_start_time"/>
  13. <result property="clinicEndTime" column="clinic_end_time"/>
  14. <result property="deptId" column="dept_id"/>
  15. <result property="deptName" column="dept_name"/>
  16. <result property="imageUrl" column="image_url"/>
  17. <result property="clinicName" column="clinic_name"/>
  18. <result property="clinicStatus" column="clinic_status"/>
  19. <result property="lastModifyUserType" column="last_modify_user_type"/>
  20. <result property="care" column="care"/>
  21. <result property="lastBeforeQuestionTime" column="last_modify_question_time"/>
  22. <result property="questionAnswerId" column="question_answer_id"/>
  23. <result property="doctorId" column="doctor_id"/>
  24. <result property="doctorNickname" column="doctor_nickname"/>
  25. <result property="lastPainAssessmentTime" column="last_pain_assessment_time"/>
  26. <result property="lastAfterQuestionTime" column="last_after_question_time"/>
  27. </resultMap>
  28. <resultMap id="RoomAndPatient" type="cn.tr.module.smart.app.controller.vo.WxDoctorClinicRoomVO">
  29. <result property="clinicRoomId" column="id"/>
  30. <result property="clinicName" column="clinic_name"/>
  31. <result property="clinicStartTime" column="clinic_start_time"/>
  32. <result property="deptName" column="dept_name"/>
  33. <result property="patientCode" column="patient_code"/>
  34. <result property="patientName" column="patient_name"/>
  35. <result property="patientAge" column="patient_age"/>
  36. <result property="patientGender" column="patient_gender"/>
  37. <result property="followUpCount" column="follow_up_count"/>
  38. <result property="assessCount" column="assess_count"/>
  39. </resultMap>
  40. <select id="stdSelectWxAppletClinicList" resultMap="stdWxAppletDetailResult">
  41. select
  42. bcr.id as id,
  43. bcr.patient_name as patient_name,
  44. bcr.patient_age as patient_age,
  45. bcr.patient_gender as patient_gender,
  46. bcr.patient_code as patient_code,
  47. bcr.clinic_start_time as clinic_start_time,
  48. bcr.clinic_end_time as clinic_end_time,
  49. bcr.dept_id as dept_id,
  50. bcr.dept_name as dept_name,
  51. bcr.clinic_name as clinic_name,
  52. bcr.clinic_status as clinic_status,
  53. bcrwu.care as care,
  54. bqa.id as question_answer_id,
  55. bqa.answer_time as last_modify_question_time,
  56. su.id as doctor_id,
  57. su.nickname as doctor_nickname,
  58. bp.new_human as new_human,
  59. bp.card_no as card_no,
  60. bcr.last_before_question_time as last_before_question_time,
  61. bcr.last_pain_assessment_time as last_pain_assessment_time,
  62. bcr.last_after_question_time as last_after_question_time
  63. from biz_clinic_room as bcr
  64. join biz_patient as bp on bp.id = bcr.patient_id
  65. join biz_clinic_room_wx_user as bcrwu on bcrwu.clinic_room_id = bcr.id
  66. left join biz_clinic_room_doctor_user as bcrmu on bcrmu.clinic_room_id = bcr.id
  67. left join sys_user as su on bcrmu.user_id = su.id
  68. left join biz_question_answer as bqa on bqa.clinic_id = bcr.id
  69. <where>
  70. and bcr.deleted=0 and bcrwu.wx_user_id = #{query.userId}
  71. <if test="query.patientCode != null and query.patientCode != ''">
  72. and bcr.patient_code like concat('%',#{query.patientCode},'%')
  73. </if>
  74. </where>
  75. </select>
  76. <select id="selectByClinicRoomAndPatientList" resultMap="RoomAndPatient">
  77. SELECT bcr.id,
  78. bcr.clinic_name,
  79. bcr.clinic_start_time,
  80. bcr.dept_name,
  81. bcr.patient_name,
  82. bcr.patient_age,
  83. bcr.patient_gender,
  84. bcr.patient_code,
  85. bcr.follow_up_count,
  86. bcr.assess_count
  87. FROM biz_clinic_room bcr
  88. join biz_clinic_room_doctor_user bcrmu
  89. on bcr.id = bcrmu.clinic_room_id
  90. <where>
  91. and bcr.deleted = 0
  92. <if test="source.clinicStatus != null and source.clinicStatus != ''">
  93. and bcr.clinic_status = #{source.clinicStatus ,jdbcType=VARCHAR}
  94. </if>
  95. <if test="source.queryCondition != null and source.queryCondition != ''">
  96. and (bcr.patient_code LIKE concat('%',#{source.queryCondition,jdbcType=VARCHAR},'%')
  97. or bcr.patient_name like concat('%',#{source.queryCondition,jdbcType=VARCHAR},'%'))
  98. </if>
  99. <if test="source.currentUserId != null and source.currentUserId != ''">
  100. and bcrmu.user_id = #{source.currentUserId,jdbcType=VARCHAR}
  101. </if>
  102. </where>
  103. </select>
  104. <select id="stdWxAppletSelectByPatientCodeAndClinicStartTime"
  105. resultType="cn.tr.module.smart.common.po.BizClinicRoomPO">
  106. select *
  107. from biz_clinic_room
  108. where patient_code = #{patientCode}
  109. and DATE(clinic_start_time) = DATE(#{clinicStartTime})
  110. limit 1
  111. </select>
  112. <select id="stdSelectWxAppletById" resultMap="stdWxAppletDetailResult">
  113. select
  114. bcr.id as id,
  115. bcr.patient_name as patient_name,
  116. bcr.patient_age as patient_age,
  117. bcr.patient_gender as patient_gender,
  118. bcr.patient_code as patient_code,
  119. bcr.clinic_start_time as clinic_start_time,
  120. bcr.clinic_end_time as clinic_end_time,
  121. bcr.dept_id as dept_id,
  122. bcr.dept_name as dept_name,
  123. bcr.clinic_name as clinic_name,
  124. bcr.clinic_status as clinic_status,
  125. bcrwu.care as care,
  126. bqa.id as question_answer_id,
  127. bqa.answer_time as last_modify_question_time,
  128. su.id as doctor_id,
  129. su.nickname as doctor_nickname,
  130. bcr.last_before_question_time as last_before_question_time
  131. from biz_clinic_room as bcr
  132. join biz_clinic_room_wx_user as bcrwu on bcrwu.clinic_room_id = bcr.id
  133. left join biz_clinic_room_doctor_user as bcrmu on bcrmu.clinic_room_id = bcr.id
  134. left join sys_user as su on bcrmu.user_id = su.id
  135. left join biz_question_answer as bqa on bqa.clinic_id = bcr.id
  136. where bcr.id = #{id}
  137. </select>
  138. <select id="selectClinicByCondition" resultType="cn.tr.module.smart.common.dto.BizClinicRoomDTO">
  139. SELECT
  140. bcr.id as id,
  141. bcr.clinic_name as clinicName ,
  142. bcr.patient_age as patientAge,
  143. bcr.dept_id as deptId,
  144. bcr.clinic_start_time as clinicStartTime,
  145. bcr.clinic_end_time as clinicEndTime,
  146. bcr.clinic_status as clinicStatus,
  147. bcr.last_follow_up_time as lastFollowUpTime,
  148. bcr.follow_up_count as followUpCount,
  149. bcr.follow_up as followUp,
  150. bcr.patient_id as patientId,
  151. bcr.patient_code as patientCode,
  152. bcr.patient_name as patientName,
  153. bcr.dept_name as deptName,
  154. bcr.patient_gender as patientGender,
  155. bcr.last_care_time as lastCareTime,
  156. bcr.last_question_time as lastQuestionTime,
  157. bcr.create_time as create_time,
  158. bcr.create_by as create_by,
  159. bcr.update_time as update_time,
  160. bcr.update_by as update_by
  161. FROM
  162. biz_clinic_room bcr
  163. LEFT JOIN biz_clinic_room_wx_user bcrwu ON bcr.id = bcrwu.clinic_room_id
  164. LEFT JOIN biz_clinic_room_doctor_user bcrdu on bcr.id = bcrdu.clinic_room_id
  165. <where>
  166. and bcr.deleted = 0
  167. <if test="queryDTO.deptId != null and queryDTO.deptId != ''">
  168. and bcr.dept_id = #{queryDTO.deptId}
  169. </if>
  170. <if test="queryDTO.phase != null and queryDTO.phase != ''">
  171. and bcr.clinic_status = #{queryDTO.phase}
  172. </if>
  173. <if test="queryDTO.isDoctorBind != null and queryDTO.isDoctorBind">
  174. and bcrdu.id is not null
  175. </if>
  176. <if test="queryDTO.isPatientBind != null and queryDTO.isPatientBind">
  177. and bcrwu.id is not null
  178. </if>
  179. <if test="queryDTO.timeRange != null and queryDTO.timeRange.size>0">
  180. and bcr.clinic_start_time &gt;= #{queryDTO.timeRange[0]}
  181. </if>
  182. <if test="queryDTO.timeRange != null and queryDTO.timeRange.size>1">
  183. and bcr.clinic_start_time &lt;= #{queryDTO.timeRange[1]}
  184. </if>
  185. <if test="queryDTO.condition != null and queryDTO.condition != ''">
  186. and (bcr.patient_code LIKE concat('%',#{queryDTO.condition,jdbcType=VARCHAR},'%')
  187. or bcr.patient_name like concat('%',#{queryDTO.condition,jdbcType=VARCHAR},'%'))
  188. </if>
  189. <if test="queryDTO.userId != null and queryDTO.userId != ''">
  190. and bcrdu.user_id = #{queryDTO.userId}
  191. </if>
  192. </where>
  193. </select>
  194. <select id="selectClinicAndDoctorByPatientIdList"
  195. resultType="cn.tr.module.smart.web.dto.BizPatientClinicListDTO">
  196. SELECT
  197. bcr.id as clinicId,
  198. bcr.clinic_name as clinicName,
  199. bcr.clinic_start_time as clinicStartTime,
  200. bcr.dept_id as deptId,
  201. bcr.dept_name as deptName,
  202. su.nickName as nickName
  203. FROM
  204. biz_clinic_room bcr
  205. JOIN biz_clinic_room_doctor_user bcrdu ON bcr.ID = bcrdu.clinic_room_id
  206. Join sys_user su on bcrdu.user_id = su.id
  207. <where>
  208. and bcr.deleted = 0
  209. <if test="patientId != null and patientId != ''">
  210. and bcr.patient_id = #{patientId}
  211. </if>
  212. </where>
  213. </select>
  214. </mapper>