VisitMapper.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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="com.ruoyi.web.work.mapper.VisitMapper">
  6. <select id="selectList" resultType="com.ruoyi.web.work.domain.Visit">
  7. select * from tb_visit v
  8. <where>
  9. v.hospital_status = '3'
  10. <if test="id != null "> and id = #{id}</if>
  11. <if test="patId != null "> and pat_id = #{patId}</if>
  12. <if test="cardId != null "> and card_id = #{cardId}</if>
  13. <if test="patClass != null and patClass != ''"> and pat_class = #{patClass}</if>
  14. <if test="bed != null and bed != ''"> and bed = #{bed}</if>
  15. <if test="department != null and department != ''"> and department = #{department}</if>
  16. <if test="physician != null and physician != ''"> and physician = #{physician}</if>
  17. <if test="nurseCode != null and nurseCode != ''"> and nurse_code = #{nurseCode}</if>
  18. <if test="doctorCode != null and doctorCode != ''"> and doctor_code = #{doctorCode}</if>
  19. <if test="hospitalizedNumber != null and hospitalizedNumber != ''"> and hospitalized_number = #{hospitalizedNumber}</if>
  20. <if test="feeCategory != null and feeCategory != ''"> and fee_category = #{feeCategory}</if>
  21. <if test="dischargeMethod != null and dischargeMethod != ''"> and discharge_method = #{dischargeMethod}</if>
  22. <if test="medicalCode != null and medicalCode != ''"> and medical_code = #{medicalCode}</if>
  23. <if test="hospitalStatus != null and hospitalStatus != ''"> and hospital_status = #{hospitalStatus}</if>
  24. <if test="registrationStatus != null and registrationStatus != ''"> and registration_status = #{registrationStatus}</if>
  25. <if test="admissionTime != null and admissionTime != ''"> and admission_time = #{admissionTime}</if>
  26. <if test="dischargeTime != null and dischargeTime != ''"> and discharge_time = #{dischargeTime}</if>
  27. <if test="level != null and level != ''"> and level = #{level}</if>
  28. <if test="reasonArea != null and reasonArea != ''"> and reasonArea = #{reasonArea}</if>
  29. <if test="wardCode != null and wardCode != ''"> and ward_code = #{wardCode}</if>
  30. <if test="wardName != null and wardName != ''"> and ward_name = #{wardName}</if>
  31. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  32. and admission_time BETWEEN #{startTime} AND #{endTime}
  33. </if>
  34. <if test="deptId != null and deptId != 0">AND (v.dept_id = #{deptId} OR v.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, parent_id) ))</if>
  35. </where>
  36. <!-- 数据范围过滤 -->
  37. ${params.dataScope}
  38. </select>
  39. <select id="getPatientCardByNameOrDepartmentOrPhysician" resultType="com.ruoyi.web.work.domain.dto.PatientCardDto">
  40. SELECT
  41. v.department,
  42. v.physician,
  43. tb_patient.`name`,
  44. v.discharge_method,
  45. v.discharge_time,
  46. v.id as visit_id,
  47. v.pat_id,
  48. v.card_id
  49. FROM
  50. tb_visit v
  51. JOIN tb_orc_report ON tb_orc_report.visit_id=v.id
  52. LEFT JOIN tb_patient ON v.pat_id = tb_patient.id
  53. LEFT JOIN sys_dept d ON d.dept_id = v.dept_id
  54. <where>
  55. v.hospital_status = '3'
  56. <if test="patientName!='' and patientName!=null">
  57. AND tb_patient.`name` like concat('%', #{patientName}, '%')
  58. </if>
  59. <if test="department!='' and department!= null">
  60. AND v.department =#{department}
  61. </if>
  62. <if test="physician!='' and physician!= null">
  63. AND v.physician like concat('%', #{physician}, '%')
  64. </if>
  65. <if test="deptId !=null and deptId != 0">AND (v.dept_id = #{deptId} OR v.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, parent_id) ))</if>
  66. <if test="startTime!=null and endTime!=null ">
  67. AND v.discharge_time BETWEEN #{startTime} AND DATE_ADD(#{endTime},INTERVAL 1 day)
  68. </if>
  69. </where>
  70. <!-- 数据范围过滤 -->
  71. ${params.dataScope}
  72. </select>
  73. <select id="selectVisitsByCardId" resultType="com.ruoyi.web.work.domain.Visit">
  74. select * from tb_visit where card_id=#{cardId}
  75. and tb_visit.hospital_status = '3'
  76. </select>
  77. <select id="selectVisitsByPatId" resultType="com.ruoyi.web.work.domain.Visit">
  78. select * from tb_visit where pat_id=#{patId}
  79. <if test="startTime != null and endTime != null">
  80. AND admission_time BETWEEN #{startTime} AND DATE_ADD(#{endTime},INTERVAL 1 day)
  81. </if>
  82. </select>
  83. <resultMap id="visitResultMap" type="visit">
  84. <id property="id" column="id"/>
  85. <result property="patId" column="pat_id"/>
  86. <result property="cardId" column="card_id"/>
  87. <result property="patClass" column="pat_class"/>
  88. <result property="deptId" column="dept_id"/>
  89. <result property="department" column="department"/>
  90. <result property="bed" column="bed"/>
  91. <result property="doctorCode" column="doctor_code"/>
  92. <result property="physician" column="physician"/>
  93. <result property="hospitalStatus" column="hospital_status"/>
  94. <result property="admissionTime" column="admission_time"/>
  95. <collection property="patients" javaType="java.util.List" resultMap="patientResultMap"/>
  96. </resultMap>
  97. <resultMap id="patientResultMap" type="patient">
  98. <id property="id" column="patient_id"/>
  99. <result property="wnPatId" column="wn_pat_id"/>
  100. <result property="name" column="name"/>
  101. </resultMap>
  102. <select id="selectVisitsByDeptId" resultMap="visitResultMap">
  103. SELECT
  104. p.id patient_id,p.wn_pat_id,p.name,
  105. v.id,v.pat_id,v.card_id,v.pat_class,v.dept_code,v.department,v.bed,v.doctor_code,v.physician,v.hospital_status,v.admission_time
  106. FROM
  107. tb_visit v
  108. LEFT JOIN sys_dept d ON v.dept_code = d.dept_code
  109. LEFT JOIN tb_patient p ON v.pat_id = p.id
  110. WHERE
  111. d.dept_id = #{deptId}
  112. </select>
  113. <select id="selectVisitsByIdAndUserName" resultMap="visitResultMap">
  114. SELECT
  115. p.id patient_id,p.wn_pat_id,p.name,
  116. v.id,v.pat_id,v.card_id,v.pat_class,v.dept_code,v.department,v.bed,v.doctor_code,v.physician,v.hospital_status,v.admission_time
  117. FROM
  118. sys_dept d
  119. LEFT JOIN sys_user u ON d.dept_id = u.dept_id
  120. LEFT JOIN tb_visit v ON u.user_name = v.doctor_code
  121. LEFT JOIN tb_patient p ON p.id = v.pat_id
  122. WHERE
  123. d.dept_id = #{deptId}
  124. AND u.user_name = #{userName}
  125. </select>
  126. </mapper>