BizClinicRoomMapper.xml 9.6 KB

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